<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
</head>
<body>

<%
    Object msg = request.getAttribute("msg")==null?"":request.getAttribute("msg");
    //通过请求对象获取所有的cookie
    Cookie[] cookies = request.getCookies();
    String username = "";
    String password = "";
    String rm = "";

    if(cookies!=null){
        //遍历cookie数组 获取 username password  rm
        for(Cookie cookie: cookies){
            if("username".equals(cookie.getName())){
                username = cookie.getValue();
            }
            if("password".equals(cookie.getName())){
                password = cookie.getValue();
            }

            if("rm".equals(cookie.getName())){
                rm = cookie.getValue();
            }
        }
    }
    String remember = "true".equals(rm)?"checked":"";
%>
    <h1>欢迎登录</h1>
<form action="/javaweb/user?method=login" method="post">
    <p><input type="text" name="username" placeholder="请输入用户名" value="<%=username%>"></p>
    <p><input type="password" name="password" placeholder="请输入密码" value="<%=password%>"></p>
    <p><input type="checkbox" name="rm" <%=remember%>>记住我</p>
    <p><input type="submit" value="立即登录"></p>
    <span style="color: red"><%=msg%></span>
</form>

</body>
</html>
